package com.sayice.robotconflict.model.logic

/**
 * 机器人逻辑
 */
data class Logic(
    /**
     * 条件
     */
    val condition: Condition? = null,

    /**
     * 任务
     */
    val task: FuncValue
)

/**
 * 条件
 */
data class Condition(
    /**
     * 条件体
     */
    var body: ConditionBody? = null,

    /**
     * 子条件
     */
    var subConds: SubConds? = null,
) {
    fun deepCopy(): Condition = copy(body = body?.deepCopy(), subConds = subConds?.deepCopy())
}

/**
 * 条件体
 */
data class ConditionBody(
    /**
     * 操作数1
     */
    val operand1: FuncValue = FuncValue(),

    /**
     * 操作数2
     */
    val operand2: FuncValue = FuncValue(),

    /**
     * 比较操作符
     */
    var operator: String = "EQ"
) {
    fun deepCopy(): ConditionBody = copy(operand1 = operand1.copy(), operand2 = operand2.copy())
}

/**
 * 子条件
 */
data class SubConds(
    /**
     * 子条件1
     */
    val subCond1: Condition = Condition(body = ConditionBody()),

    /**
     * 子条件2
     */
    val subCond2: Condition = Condition(body = ConditionBody()),

    /**
     * 逻辑操作符
     */
    var operator: String = "AND"
) {
    fun deepCopy(): SubConds = copy(subCond1 = subCond1.deepCopy(), subCond2 = subCond2.deepCopy())
}

/**
 * 函数值，可以表示操作数 (Operand) 或者任务 (Task)
 */
data class FuncValue(
    /**
     * 函数 (Operand对应简单获取函数，Task对应设置函数)
     */
    var func: String = "",

    /**
     * 参数
     */
    var params: List<Any?>? = null
)

